package org.gwu.seuss.ui.validator;

import org.gwu.seuss.communication.util.LoginValidator;
import org.gwu.seuss.communication.util.PasswordValidator;
import org.gwu.seuss.ui.commandline.BaseCommandLineArgs;

public abstract class RequestValidator {
	protected String errorMessage;
	
	protected LoginValidator loginValidator = new LoginValidator();

	public String getErrorMessage() {
		return errorMessage;
	}
	
	protected boolean isValidPassword(char[] newPassword) {
		PasswordValidator pv = new PasswordValidator();
		boolean result = pv.validate(new String(newPassword));
		errorMessage = result ? "" : "Invalid Password";
		return result;
	}
	
	protected boolean isValidLogin(String login, String eMessage){
		boolean result = loginValidator.validate(login);
		errorMessage = result ? "" : eMessage;
		return result;
	}
	
	public abstract <T extends BaseCommandLineArgs> boolean isValid(T cli);

}
